<?php
ob_start();
session_start();
$username = $_SESSION['username'];
require_once('config.php');
require_once('lib/database.php');
require_once('lib/user.php');
require_once('template/header.php');

if($_SESSION['is_logged_in']){

	if(isset($_GET['action'])){

		switch($_GET['action']){
		
			case 'read':
				require_once('template/header.php');
				
				$user = new User();
				$display_all = $user->find_all();
				echo '<pre>';
				foreach($display_all as $values){
				
					echo $values['id'] . " ";
					echo $values['username'] . " ";
					echo $values['password'] . " ";
					echo "<a href='/crud/lib/update.php?id=${values['id']}'>Update</a>" . " ";			
					echo "<a href='/crud/lib/delete.php?id=${values['id']}'>Delete</a>";
					echo "<br />";
					echo "<hr />";
				
				}
				
				require_once('template/footer.php');
				
			break;
			
			case 'update':
			
			break;
			
			case 'delete':
			
			break;
			
			default: 
			
			break;

		}
	}
} else {

	header("Location: http://localhost/crud/login.php");

}
require_once('template/footer.php');
ob_flush();
?>



